﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShuiBiaoHWH.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.ChaoBiaoGL.ShuiBiaoHWH"  Theme="Default" %>


<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../../JS/AddEditCancel.js"></script>
    <script src="../../../../JS/jquery.js"></script>
     <script type="text/javascript">
        
         function display(op, id) {
             hdCollection.Set("ID", id);
             if (op == "add") {
                 btnAdd.SetVisible(false);

                 //listCover(true, "divList");
                 //$("#GridViewContentTable").show();
                 txtSheShuiDXFLDM.Focus();
             }
             else if (op == "edit") {

                 ASPxCallback1.PerformCallback("info");
             }
             //else {
             //$("#GridViewContentTable").hide();
             //btnAdd.SetVisible(true);
             // listCover(false, "divList");
             // }
         }

         function del(id) {
             hdCollection.Set("ID", id);
             if (confirm("确认删除吗？")) {
                 ASPxCallback1.PerformCallback("del");
             }
             else {
                 hdCollection.Set("ID", 0);
             }
         }

         function save() {
             hdCollection.Set("ID", 0);
             ASPxCallback1.PerformCallback("save");
         }

         //
         function Search(s) {
             if (s.GetText() == "") {
                 alert("用户号不能为空，请输入");
                 txtYHH.Focus();
             }
             else {
                 hdCollection.Set("yhh", s.GetText());
                 ASPxCallback1.PerformCallback("Search");
             }
             OnKeyNext(txtSBH_ZLS);
         }

         function ASPxCallback1Complete(rs) {
             var arr = rs.split('|');
             var type = arr[0];
             var state = arr[1];
             if (type == "info") {
                 txtYHH.SetText(arr[2]);
                 txtYHM.SetText(arr[3]);
                 txtSBH_ZLS.SetText(arr[4]);
                 txtSBH_SZY.SetText(arr[5]);
             }
             else if (type == "save") {
                 if (arr[2] == "0") {
                     alert('保存成功！');
                     gvList.PerformCallback();
                 }
             }
             else if (type == "del") {
                 if (arr[2] == "0") {
                     alert('删除成功！');
                     gvList.PerformCallback();
                 }
             }
             else if (type == "Search") {
                 txtYHM.SetText(arr[2]);
             }
         }


         function begincall() {
             loadpanel1.Show();
         }
         function endcall() {
             loadpanel1.Hide();
             //定位添加或修改的记录
             var oid = hdCollection.Get("OperateID");
             var index = -1;
             if (oid != -1 && typeof (oid) != undefined) {
                 for (var i = 0; i < gvList.GetVisibleRowsOnPage() ; i++) {
                     if (gvList.GetRowKey(i) == oid) {
                         index = i;
                     }
                 }
                 if (index != -1) {
                     gvList.SetFocusedRowIndex(index);
                     gvList.MakeRowVisible(index);
                     hdCollection.Set("OperateID", -1);
                 }
             }
         }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            表维护
        </div>
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
             <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" ShowImage="false" Text="加载中" ></dx:ASPxLoadingPanel>
        <div style="height: 3px;"></div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

                <div id="divList" align="center">
                    <div>
                        <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1"  Width="100%" OnCustomCallback="gvList_CustomCallback">
                            <Columns>
                                <dx:GridViewDataTextColumn FieldName="S_YHH" Caption="用户号" Width="10%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_YHM" Caption="用户名" Width="20%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_SBH_ZLS" Caption="水表号-自来水" Width="10%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_SBH_SZY" Caption="水表号-水资源" Width="10%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="5%">
                                    <DataItemTemplate>
                                        <a href="#" onclick="display('edit','<%#Eval("ID")%>')">修改</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="5%">
                                    <DataItemTemplate>
                                       <a href="#" onclick="del('<%#Eval("ID")%>')">删除</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <Settings  VerticalScrollableHeight= "300" VerticalScrollBarMode="Auto"  />
                            <ClientSideEvents   BeginCallback="function(s,e){begincall();}" EndCallback="function(s,e){endcall();}"  />
                        </dx:ASPxGridView>
                    </div>
                    <div style="height: 3px;"></div>
                   <%-- <div style="text-align: right">
                        <hr />
                        <dx:ASPxButton ID="btnAdd" ClientInstanceName="btnAdd" runat="server" Text="添加" AutoPostBack="false"  ClientSideEvents-Click="function(s,e){display('add',-1)}"  UseSubmitBehavior="false">
                        </dx:ASPxButton>
                    </div>--%>
                    <div id="GridViewContentTable" >
                       <%-- <div class="tabletitle1" align="center">
                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="添加"></dx:ASPxLabel>
                        </div>--%>
                        <table style="width: 80%; margin: auto;">
                            <tr>
                                <td align="right" style="width: 40%">用户号：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtYHH" ClientInstanceName="txtYHH" runat="server" Width="60%" MaxLength="15">                                        
                                        <ClientSideEvents KeyPress="function(s,e){var code=event.keyCode;if(code==13){Search(s);}}" />
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                             <tr>
                                <td align="right" style="width: 40%">用户名：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtYHM" ClientInstanceName="txtYHM" runat="server" Width="80%" ClientEnabled="false">                                        
                                        
                                    </dx:ASPxTextBox>
                                </td>
                            </tr> 
                            <tr>
                                <td align="right">水表号-自来水：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtSBH_ZLS" ClientInstanceName="txtSBH_ZLS" runat="server" Width="60%" MaxLength="30">                                       
                                        <ClientSideEvents  KeyPress="function(s,e){OnKeyNext(txtSBH_SZY);}" />
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">水表号-水资源：
                                </td>
                                 <td>
                                    <dx:ASPxTextBox ID="txtSBH_SZY" ClientInstanceName="txtSBH_SZY" runat="server" Width="60%" MaxLength="30">                                       
                                        <ClientSideEvents  KeyPress="function(s,e){OnKeyNext(btnSave);}" />
                                    </dx:ASPxTextBox>
                                </td> 
                            </tr>
                           
                        </table>
                        <table id="GridViewButtonTable" runat="server" style="width:100%">
                            <tr>
                                <td><hr /></td>
                            </tr>
                            <tr>
                                <td style="text-align: right;">
                                    <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存" UseSubmitBehavior="false" AutoPostBack="false">
                                        <ClientSideEvents Click="function(s, e) {save();}" />
                                    </dx:ASPxButton>
                                    <dx:ASPxButton  ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" UseSubmitBehavior="false" >
                                        <ClientSideEvents  Click="function(s,e){display('init',-1);}"/>
                                        </dx:ASPxButton>
                                </td>
                            </tr>
                        </table>                        
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
 
